<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"    
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:c="http://java.sun.com/jsp/jstl/core"
      xmlns:f="http://java.sun.com/jsf/core">
   
<h:head>
	<title>Market Grabber - Select Offer</title>
</h:head>

<h:body>
	<ui:composition template="./template.xhtml">
		<ui:define name="siteheader">
                Select Offer
        </ui:define>
		<ui:define name="leftmenu">
    		<li><h:link outcome="inbox">Inbox</h:link></li>
		</ui:define>

		<ui:define name="maincontent">
		
			<p>Please select the offer you want to order.</p>
			
			<br/>
		
			<h:form>
				
				 <h:dataTable var="o" value="#{user.offers}">
                    <h:column>
                            <f:facet name="header">Supplier</f:facet>
                            <h:outputText value="#{o.supplier.name}"/>
                    </h:column>
                    
                    <h:column>
	                    <h:dataTable var="i" value="#{o.items}">
	                    <h:column>
	                    		  <f:facet name="header">Amount</f:facet>
	                            <h:outputText value="#{i.amount}"/>
	                    </h:column>
	                    <h:column>
	                            <f:facet name="header">Good</f:facet>
	                            <h:outputText value="#{i.good}"/>
	                    </h:column>
	                    <h:column>
	                            <f:facet name="header">Price</f:facet>
	                            <h:outputText value="#{i.price}"/>
	                    </h:column>	
	                    </h:dataTable>
                    </h:column>
                    <h:column>
                            <h:commandButton value="Select" action="#{user.selectOffer}">
                                   <f:setPropertyActionListener target="#{user.selectedOffer}" value="#{o}" /> 
                            </h:commandButton>
                            
                    </h:column>
            </h:dataTable>
           
				
			</h:form>
			
		</ui:define>
	</ui:composition>
</h:body>
</html>
